#include "destructor.hpp"

void f1()
{
    //分别new一个父类对象和子类对象，并均用父类指针指向它们
	Person* p1 = new Person;
	Person* p2 = new Student;

	//使用delete调用析构函数并释放对象空间
	delete p1;
	delete p2;
}


class A
{
public:
	A(char* s) { cout << s << endl; }
	A(char* s, char* s1) { cout << s << endl; cout << s1 << endl;}
	~A() {};
};
class B : virtual public A
{
public:
	B(char* s1, char* s2)
		:A(s1)
	{
		cout << s2 << endl;
	}
};
class C : virtual public A
{
public:
	C(char* s1, char* s2)
		:A(s1)
	{
		cout << s2 << endl;
	}
};
class D : public B, public C
{
public:
	D(char* s1, char* s2, char* s3, char* s4)
		:B(s1, s2)
		, C(s1, s3)
		, A(s1, s1)
	{
		cout << s4 << endl;
	}
};
int main()
{
	D* p = new D("class A", "class B", "class C", "class D");
	delete p;
	return 0;
}

